from selenium import webdriver
from lxml import  etree
from time import sleep

bro = webdriver.Chrome(executable_path='./chromedriver.exe')

bro.get('http://scxk.nmpa.gov.cn:81/xk/')

# 获取浏览器当前页面的页面源码数据
page_text = bro.page_source

'//*[@id="gzlist"]'

# 解析企业名称

tree = etree.HTML(page_text)
li_list = tree.xpath('//*[@id="gzlist"]/li')
for li in li_list:
    name = li.xpath('./dl/@title')[0]
    # print(name)


sleep(4)
bro.quit()

#
# bro = webdriver.Chrome(executable_path='./chromedriver.exe')
#
# bro.get('https://www.taobao.com/')
#
# # 标签定位
# search_input = bro.find_element_by_id('q')
# # 标签交互
# search_input.send_keys('ipone')
#
# # 执行js
# bro.execute_script('windows.scrollTo(0,document.body.scrollHeight)')
# # 点击搜索按钮
# # bro.find_element_by_class_name()
# btn = bro.find_element_by_css_selector('.btn-search')
# btn.click()
#
# sleep(5)
#
# bro.quit()

from selenium import webdriver
from selenium.webdriver import ActionChains
import time
browser = webdriver.Chrome()
url = 'http://www.runoob.com/try/try.php?filename=jqueryui-api-droppable'
browser.get(url)
browser.switch_to.frame('iframeResult')
source = browser.find_element_by_css_selector('#draggable')
target = browser.find_element_by_css_selector('#droppable')
actions = ActionChains(browser)
# actions.drag_and_drop(source, target)
actions.click_and_hold(source)
time.sleep(3)
for i in range(5):
    actions.move_by_offset(xoffset=17,yoffset=0).perform()
    time.sleep(0.5)
actions.release()